package com.pan.cuiniubi.utils;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;

public class WriterTool {

    public static void output(String path,String content){
        File file = new File(path);
        if (!file.exists()) {
            try {
                file.createNewFile();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        try {
            // FileWriter(File file, boolean append)，append为true时为追加模式，false或缺省则为覆盖模式
            Writer writer = new FileWriter(path,false);
            writer.write(content);
            writer.flush();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

    }
}
